package br.com.farmabid.component;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Specializes;

import br.com.caelum.vraptor.Convert;
import br.com.caelum.vraptor.converter.IntegerConverter;

@Specializes
@Convert(Integer.class)
@ApplicationScoped
public class IntegerConversor extends IntegerConverter {

	public Integer convert(String string, Class<? extends Integer> arg1) {
		if(!StringUteis.isEmpty(string.trim())){
			string = string.replaceAll("[^0-9]", "");
			if(!StringUteis.isEmpty(string.trim())){
				return Integer.parseInt(string);
			} else {
				return null;
			}
		} else {
			return null;
		}
	}

}